package actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import dao.AktieDAO;

public class StornoAction extends Action{

	@Override
	public String execute(HttpServletRequest request, HttpSession s)
			throws Exception {
		
		
		try{
			int idStornoAktie = Integer.valueOf(request.getParameter("aktienID"));
			
			if(AktieDAO.getInstance().stornoAktie(idStornoAktie)){
				setApplicationMessage(s, getMessageProperty("auftragStorno"));
				return getForwardProperty("offeneAuftraege");
			}
			else{
				setApplicationMessage(s, getMessageProperty("unerwarteterFehler"));
				return getForwardProperty("offeneAuftraege");
			}
		}catch(NumberFormatException nfe){
			nfe.printStackTrace();
			setApplicationMessage(s, getMessageProperty("unerwarteterFehler"));
			return getForwardProperty("offeneAuftraege");
		}
	}

}
